<template>
  <div id="selectionlist">
    <div v-if="listLoading">
      读取中...
    </div>
    <div v-else>
      <el-button type="primary" @click="exportdoc" style="margin:15px 15px 0;">导出动议签报</el-button>
      <meetingDetail :downloadfiles="downloadfiles" :personlist="personlist" :changeId="personId" :dongyishowForm="dongyishowForm"></meetingDetail>
    </div>
  </div>
</template>

<script>
import Qs from 'qs'
import meetingDetail from './common/meetingDetail'
export default {
  components: {
    meetingDetail
  },
  props: ['personId'],
  watch: {
    personId: {
      handler (newName, oldName) {
        this.getpersonlist()
      },
      immediate: true
    }
  },
  data () {
    return {
      listLoading: false,
      personlist: [],
      dongyishowForm: {
        meetdate: '',
        meetnum: '',
        buleader: '',
        sileader: ''
      },
      downloadfiles: []
    }
  },
  methods: {
    exportdoc () {
      window.open(this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/selection/document/exportChangeDoc?changeId=' + parseInt(this.personId))
    },
    getpersonlist () {
      if (this.personId !== '0') {
        this.listLoading = true
        this.$http
          .post(this.$http.defaults.selectionAPI + `api/change/getChangeProposalPersons/`, Qs.stringify({id: parseInt(this.personId)}))
          .then(response => {
            if (response.data.success) {
              this.step = response.data.result.state
              this.personlist = response.data.result.persons
              // for (let i = 0; i < response.data.result.persons.length; i++) {
              //   console.log(JSON.stringify(response.data.result.persons[i]))
              //   this.personlist.push(response.data.result.persons[i])
              //   this.personlist[i].currentJobDescription = response.data.result.persons[i].currentJob.split(' ')[1]
              //   this.personlist[i].currentJob = response.data.result.persons[i].currentJob.split(' ')[0]
              //   this.personlist[i].jobDescription = response.data.result.persons[i].jobName.split(' ')[1]
              //   this.personlist[i].jobName = response.data.result.persons[i].jobName.split(' ')[0]
              // }
              console.log(JSON.stringify(this.personlist))
              if (response.data.result.meeting) {
                this.dongyishowForm.sileader = response.data.result.meeting.leader2Opionion
                this.dongyishowForm.buleader = response.data.result.meeting.leaderOpinion
                this.dongyishowForm.meetnum = response.data.result.meeting.meetingNumber
                this.dongyishowForm.meetdate = response.data.result.meeting.meetingTime
              }
              this.downloadfiles = response.data.result.files
            } else {
              this.$message({
                message: '获取失败:' + response.data.message,
                type: 'error'
              })
            }
            this.listLoading = false
          })
          .catch(error => {
            console.log(error)
            this.$message({
              message: '获取失败:' + error,
              type: 'error'
            })
            this.listLoading = false
          })
      }
    }
  }
}
</script>
<style>
  #selectionlist .wboxnoborder .el-table{
    border: #95B8E7 solid 1px;
  }
  #selectionlist .wboxnoborder .el-table th{
    font-weight: normal;
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
    text-align: center;
    border-right: #95B8E7 solid 1px;
    border-bottom: #95B8E7 solid 1px;
    min-height: 30px;
    line-height:30px;
  }
  #selectionlist .wboxnoborder .el-table td, .el-table th{
    padding:0;
    font-size:var(--size14) !important;
    line-height: 20px;
    font-family: '宋体';
    text-align: center;
  }
  #selectionlist .el-table__row{
    height: 50px;
  }
  #selectionlist .el-upload-list{
    width: 700px !important;
  }
</style>
<style scoped>
  h1{
    font-size:var(--size16) !important;
    font-weight: bolder;
    height: 30px;
    border-bottom: 1px solid #95B8E7;
    font-family: '宋体';
    line-height: 30px;
    color: #000;
    padding-left:10px;
    background-image: linear-gradient(to bottom , #EEF4FF, #E0ECFF);
    margin:0;
  }
  .el-pagination{
    float: left;
    padding:7px 10px;
  }
  .wboxs{
    padding:5px 15px;
    width: calc(100% - 30px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
  #selectionlist .wboxnoborder{
    padding:0;
    width: calc(100% - 0px);
    background: #fff;
    margin:0 10px;
    overflow: hidden;
  }
</style>
